<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page import="com.hnas.core.util.PropertyUtil"%>
<%@page import="com.hnas.core.dto.DataBean"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>对账信息</title>
<script type="text/javascript">
</script>
</head>
<body>
	<!-- 标题 -->
	<div class="titleBar m_b_20">
		<div class="tit fl b_l_e74a5f">
			<h3 class="cn">对账信息</h3>
			<span class="en">gen reconciliation log information</span>
		</div>
		<div class="fr"></div>
	</div>
	<!-- end 标题 -->

	<form method="post" action="${pageContext.request.contextPath }/backend/genReconciliationLog/logList" name="searchForm"  >
  	<input type="hidden" name="pageNo" value="${dto.pageNo}">
  	<input type="hidden" name="totalCount" value="${dto.totalCount}">
	<!-- 查询 -->
	<div class="box_03 p_20 m_b_20">
		<table class="tb_style02" width="100%">
	        <tr>
	        	<th style="width:160px;">开始时间</th>
               	<td>
               		<input type="text" style="width:160px;" name="startDate" id="startDate" value="${dto.startDate}" style="width:100px;" class="input_style2"/>
                </td>
                <th style="width:160px;">结束时间</th>
               	<td>
               		<input type="text" style="width:160px;" name="endDate" id="endDate" value="${dto.endDate}" style="width:100px;" class="input_style2"/>
                </td>
	            <th>每页显示</th>
	            <td colspan="5">
	            	<input style="width:50px;" class="input_style2" type="text" placeholder="" id="pageSize" name="pageSize" value="${dto.pageSize}"> 条
	                <span style="margin-left:170px;">
	                	<input style="width:110px;" class="btn_brown02 m_r_12" type="button" name="searchData" id="searchData" value="查  询">
	                </span>
	            </td>
	         </tr>
		</table>
	</div>
	<!-- end 查询 -->
				
</form>

<div class="m_b_20">
	<table class="tb_style05" width="100%" style="table-layout:fixed;">
		<thead>
		<tr>
			<c:forEach items="${beans}" var="o">
			<c:if test="${o.display && !o.hidden}"><th align="center">${o.title}</th></c:if>
			</c:forEach>
			<th width="100">操作</th>
		</tr>
		</thead>
		<tbody>
			<c:forEach items="${pg.list}" var="o">
			<tr>
				<c:forEach items="${beans}" var="o1">
					<c:if test="${o1.display && !o1.hidden}">
					<td style="word-wrap:break-word;" align="center"><%=String.valueOf(PropertyUtil.getValue(pageContext.getAttribute("o"),((DataBean)pageContext.getAttribute("o1")).getField())).replace("false","否").replace("true","是")%></td></c:if>
				</c:forEach>
					<td>
					 	<c:if test="${o.status == '3'}">生成文件中</c:if>
					 	<c:if test="${o.status == '4'}">人工干预</c:if>
						<a href="#" class="c_3366cc btn descriptionData" fileDate="${o.fileDate }" id="${o.id }" status="${o.status }" fileType = "${o.fileType }">
							<c:if test="${o.status == '2'}">重新生成</c:if>
							<c:if test="${o.status == '1'}">查看描述</c:if>
						</a>&nbsp;&nbsp;
					</td>
			</tr>
			</c:forEach>
		</tbody>
	</table>
	<div class="searpage" align="right"><div>${pg.pageStr}</div></div><br/>
</div>

<script>
	function gotoJumpPage(){
		var jumpNum= $("#jumpNum").val();
		$("#search_page_size").val($("#id_page_size").val());
		gotoPage(jumpNum);
		return false;
	}
	$(function(){
		$("#searchData").click(function(){
			/** 校验输入页数是否非法  **/
			var pageSize=$("#pageSize").val();
			var reg = new RegExp("^[0-9]*$");
			if($.trim(pageSize)!=""){
				if(!reg.test($.trim(pageSize))){
					alert("每页显示数请输入非负整数");
	 				return false;
				}
			}
			if($.trim(pageSize)==""){
				alert("每页显示数不应许为空");
				return false;
			}
			doSubmit();
		});
		
		$(".descriptionData").click(function(){
			var id = $(this).attr("id");
			var fileType = $(this).attr("fileType");
			var date = $(this).attr("fileDate");
			var status = $(this).attr("status");
			if('1' == status){
				window.location.href = "${pageContext.request.contextPath }/backend/genReconciliationLog/showDescription?logId="+id+"&fileType="+fileType;
			}
			
			if('2' == status){
				//重新对账
				$.ajax({
					url:"${pageContext.request.contextPath }/backend/genridingCode/manualRecon?date="+date,
					type: 'POST',
					error: function(XMLHttpRequest, textStatus, errorThrown){
						 $.dialog.alert({title:"保存",content:"加载数据异常。"});
					},
					success: function(data){
						doSubmit();
					}
				}); 
				$(this).attr("status",3);
				$(this).text("生成文件中");
			}
			
			if('3' == status){
				alert("正在为您生成对账文件，请等待...");
			}
			
		});
		
		$("#startDate").datepicker({
			dateFormat:'yymmdd',
			changeYear: true,
			changeMonth: true,
			yearRange: "1900:2049" 
		});
		
		$("#endDate").datepicker({
			dateFormat:'yymmdd',
			changeYear: true,
			changeMonth: true,
			yearRange: "1900:2049" 
		});
		
	});
</script>
</body>
</html>